﻿using System;
using UnityEngine;

namespace UniRx.Examples
{
	// Token: 0x020001ED RID: 493
	public class Sample09_EventHandling : MonoBehaviour
	{
		// Token: 0x14000001 RID: 1
		// (add) Token: 0x06000A4D RID: 2637 RVA: 0x00037698 File Offset: 0x00035A98
		// (remove) Token: 0x06000A4E RID: 2638 RVA: 0x000376D0 File Offset: 0x00035AD0
		public event EventHandler<Sample09_EventHandling.MyEventArgs> FooBar;

		// Token: 0x14000002 RID: 2
		// (add) Token: 0x06000A4F RID: 2639 RVA: 0x00037708 File Offset: 0x00035B08
		// (remove) Token: 0x06000A50 RID: 2640 RVA: 0x00037740 File Offset: 0x00035B40
		public event Action<int> FooFoo;

		// Token: 0x170000CB RID: 203
		// (get) Token: 0x06000A51 RID: 2641 RVA: 0x00037776 File Offset: 0x00035B76
		public IObservable<int> OnBarBar
		{
			get
			{
				return this.onBarBar;
			}
		}

		// Token: 0x06000A52 RID: 2642 RVA: 0x00037780 File Offset: 0x00035B80
		private void Start()
		{
			Observable.FromEventPattern<EventHandler<Sample09_EventHandling.MyEventArgs>, Sample09_EventHandling.MyEventArgs>((EventHandler<Sample09_EventHandling.MyEventArgs> h) => new EventHandler<Sample09_EventHandling.MyEventArgs>(h.Invoke), delegate(EventHandler<Sample09_EventHandling.MyEventArgs> h)
			{
				this.FooBar += h;
			}, delegate(EventHandler<Sample09_EventHandling.MyEventArgs> h)
			{
				this.FooBar -= h;
			}).Subscribe<EventPattern<Sample09_EventHandling.MyEventArgs>>().AddTo(this.disposables);
			Observable.FromEvent<EventHandler<Sample09_EventHandling.MyEventArgs>, Sample09_EventHandling.MyEventArgs>((Action<Sample09_EventHandling.MyEventArgs> h) => delegate(object sender, Sample09_EventHandling.MyEventArgs e)
			{
				h(e);
			}, delegate(EventHandler<Sample09_EventHandling.MyEventArgs> h)
			{
				this.FooBar += h;
			}, delegate(EventHandler<Sample09_EventHandling.MyEventArgs> h)
			{
				this.FooBar -= h;
			}).Subscribe<Sample09_EventHandling.MyEventArgs>().AddTo(this.disposables);
			Observable.FromEvent<int>(delegate(Action<int> h)
			{
				this.FooFoo += h;
			}, delegate(Action<int> h)
			{
				this.FooFoo -= h;
			}).Subscribe<int>().AddTo(this.disposables);
			int capture = 0;
			Observable.FromEventPattern<EventHandler<Sample09_EventHandling.MyEventArgs>, Sample09_EventHandling.MyEventArgs>(delegate(EventHandler<Sample09_EventHandling.MyEventArgs> h)
			{
				capture.GetHashCode();
				return new EventHandler<Sample09_EventHandling.MyEventArgs>(h.Invoke);
			}, delegate(EventHandler<Sample09_EventHandling.MyEventArgs> h)
			{
				this.FooBar += h;
			}, delegate(EventHandler<Sample09_EventHandling.MyEventArgs> h)
			{
				this.FooBar -= h;
			}).Subscribe<EventPattern<Sample09_EventHandling.MyEventArgs>>().AddTo(this.disposables);
			this.OnBarBar.Subscribe<int>().AddTo(this.disposables);
			this.onBarBar.OnNext(1);
		}

		// Token: 0x06000A53 RID: 2643 RVA: 0x000378C2 File Offset: 0x00035CC2
		private void OnDestroy()
		{
			this.disposables.Dispose();
		}

		// Token: 0x040006BE RID: 1726
		private CompositeDisposable disposables = new CompositeDisposable();

		// Token: 0x040006BF RID: 1727
		private Subject<int> onBarBar = new Subject<int>();

		// Token: 0x020001EE RID: 494
		public class MyEventArgs : EventArgs
		{
			// Token: 0x170000CC RID: 204
			// (get) Token: 0x06000A57 RID: 2647 RVA: 0x0003790E File Offset: 0x00035D0E
			// (set) Token: 0x06000A58 RID: 2648 RVA: 0x00037916 File Offset: 0x00035D16
			public int MyProperty { get; set; }
		}
	}
}
